﻿@{
    ViewBag.Title = "newindex";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>         
}

<form id="form1" method="post">
<div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;">                
    <table style="width:100%;">
        <tr>
            <td style="white-space:nowrap;">
                @Html.Partial("~/Views/Modular/SearchInfo.cshtml")
            </td>
            <td style="width:100%;">
                <span class="separator"></span>
                <a class="mini-button" iconCls="icon-ok" onclick="onSelectGoods" plain="true">选择</a>
                <span class="separator"></span>
                    <a class="mini-button" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
            </td>
        </tr>
    </table>                
</div>
<div class="mini-splitter" style="width:100%;height:470px;">
    <div size="230" showcollapseButton="true">
        <div class="mini-fit">
            <ul id="tree1" class="mini-tree" url="" 
                style="width:100%;height:420px;" expandOnLoad="0"
                textField="FName" idField="FItemID" parentField="FParentID"  showTreeIcon="true" resultAsTree="false">        
            </ul>
        </div>
    </div>
    <div showCollapseButton="true">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:90%;" pageSize="10" idField="FItemID" 
            multiSelect="true"  allowCellSelect="true" allowCellEdit="true" showColumnsMenu="true"
            borderStyle="border:0;" url="../GetItem/GetGoodsList" fitColumns="false"  
            onrowdblclick="onSelectOne" sortMode="client" onlyCheckSelection ="true">
                <div property="columns">
                <div type="checkcolumn"></div>      
                <div type="indexcolumn" width="35" headerAlign="center" >序号</div>
                <div field="FItemID" width="80" visible = "false" headerAlign="center" >内码</div>             
                <div field="FNumber" width="120" allowSort="true" headerAlign="center" >编码</div>                                        
                <div field="FName" width="200" allowSort="true" headerAlign="center" >名称</div>   
                <div field="FSpec" width="100" allowSort="true" headerAlign="center" >规格</div> 
                <div field="FUnitName" width="50" allowSort="true" headerAlign="center" >单位</div> 
                <div field="FCode" width="120" allowSort="true" headerAlign="center" >条码</div> 
                <div field="FPosPrice" width="70" allowSort="true" headerAlign="center"  numberFormat="#,0.00">零售价</div> 
                <div field="FMallPrice" width="70" allowSort="true" headerAlign="center"  numberFormat="#,0.00">商城价</div> 
                <div field="FSelPrice" width="70" allowSort="true" headerAlign="center"  numberFormat="#,0.00">批发价</div> 
            </div>
        </div>  
    </div>
</div>

    <script type="text/javascript">
        //通用shown自动调用些方式
        function FormShown() {
            mini.parse();
            LoadListTree();
            var tree = mini.get("tree1");
            tree.on("nodeselect", function (e) {
                LoadListData();
            });
        }

        //加载分类树
        function LoadListTree() {
            var tree = mini.get("tree1");
            var mAppID = parent.window.getSystemAppID();
            $.post('../Goods/GetGoodsClassTree', { mjson: mAppID }, function (data) {
                tree.loadList(mini.decode(data));
                tree.select(0);
            });
        }

        function setkeyPress() {
            if (event.keyCode == 13) {
                LoadListData();
            }
        }

        //加载资料
        function SetData(data) {
            if (data.key != null) {
                mini.getbyName("FSearchKey").setValue(data.key);
            }
            LoadListTree();
        }

        //加载资料
        function search() {
            LoadListTree();
        }


        //加载用户列表
        function LoadListData() {
            var tree = mini.get("tree1");
            var mload = tree.getData();
            if (mload.length > 0) {
                var node = tree.getSelectedNode();
                var classid = node.FItemID;
                var json = "[{";
                json = json + "'mClassID':" + "'" + classid + "',";
                json = json + "'mNumber':" + "'" + mini.getbyName("FSearchKey").getValue() + "',";
                json = json + "'FSystemAppID':'" + parent.window.getSystemAppID() + "'}]";
                var grid = mini.get("datagrid1");
                grid.load({ datajson: json });
            }
        }

        function onSelectGoods(e) {
            var grid = mini.get("datagrid1");
            var rec = grid.getSelecteds();
            if (rec) {
                CloseWindow(rec);
            }
        }
    </script>
</form>


